package com.jf3q.front.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jf3q.common.domain.EduOrder;
import com.jf3q.common.vo.ResultVo;
import com.jf3q.front.service.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
@Tag(name = "订单")
public class OrderController {

    @Autowired
    OrderService orderService;

    @PostMapping("/getListOrder/{oid}")
    @Operation(summary = "查看订单")
    public ResultVo getListOrder(@PathVariable String oid,@RequestParam(defaultValue = "1")Integer pageNum,@RequestParam(defaultValue = Integer.MAX_VALUE+"") Integer pageSize){

        Page<EduOrder> page=orderService.page(new Page<>(pageNum,pageSize),new LambdaQueryWrapper<EduOrder>().eq(EduOrder::getMemberId,oid));
        return ResultVo.success("",page);
    }


    @GetMapping("/{orderId}")
    @Operation(summary = "订单详情")
    public ResultVo getOrder(@PathVariable String orderId) {
        EduOrder order = orderService.getOrder(orderId);
        return ResultVo.success("订单详情", order);
    }





}
